package com.qdxwx.data.mapper.order;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.models.order.Order;
import com.qdxwx.models.order.OrderQuery;
import com.qdxwx.models.order.OrderVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Repository
public interface OrderMapper {
	
	/**
	 * 创建订单 
	 * @param order  订单实体
	 * @return 订单ID
	 */
	int insertOrder(Order order);

	/**
	 *
	 * @param id
	 * @return
	 */
	int deleteOrderById(int id);

	/**
	 * 更新订单
	 * @param order 订单实体
	 */
	int updateOrder(Order order);
	/**
	 * 取消或恢复订单
	 * @param order 订单实体
	 */
	int updateOrderStatus(Order order);
	/**
	 * 更新订单状态为成功
	 *
	 * @param order
	 */
	int updateOrderStatusSuccess(Order order);
	/**
	 * 通过ID，查询订单数据
	 * @param orderId 订单ID
	 * @return 返回 Order
	 */
	Order selectOrderById(int orderId);
	/**
	 * 根据orderNo获取Order
	 *
	 * @param orderNo
	 * @return Order
	 */
	Order selectOrderByOrderNo(String orderNo);

	List<Order> selectOrderList(@Param("e") OrderQuery order, @Param("page")PageRequest page);

	int countOrder(@Param("e") OrderQuery order);
	/**
	 * 订单分页查询 ,根据条件
	 *
	 * @return List
	 */
	List<OrderVO> selectOrderListForUc(@Param("e") OrderQuery queryOrder, @Param("page") PageRequest page);

	Long sumPayAmount(@Param("e") OrderQuery order);

	List<Order> selectListByTeacher(@Param("e") OrderQuery order, @Param("page")PageRequest page);

	long countByTeacher(@Param("e") OrderQuery order);

	Order selectRepeatOrder(long userId, int otherId, String orderType);

    int updateCombine(long userId1, long userId2);
}
